<template>
  <div class="my-table">
    <el-form>
      <el-form-item :label="item.label" :key="i" v-for="(item,i) in tableData.formItemList">
        <el-date-picker
          v-if="item.showTime"
          class="date-picker"
          v-model="item.val"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
        <el-input placeholder="请输入内容" v-else clearable v-model="item.val"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" class="btn" @click="$emit('search', tableData.formItemList)">查询</el-button>
      </el-form-item>
    </el-form>
    <div class="mid">
      <div v-for="(item,i) in tableData.priceList" :key="i"><span>{{item.title}}：</span>{{item.price}}</div>
    </div>
    <el-table :data="tableData.tableList" border style="width: 100%">
      <el-table-column v-for="(item,i) in tableData.columnList" :key="i" show-overflow-tooltip align="center" :prop="item.name" :label="item.title"></el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="tableData.currentPage"
      :page-size="tableData.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.total">
    </el-pagination>
  </div>
</template>
<script>
export default {
  props: {
    tableData: {
      required: true,
      type: Object,
      priceList: {
        required: true,
        type: Array
      },
      tableList: {
        required: true,
        type: Array
      },
      columnList: {
        required: true,
        type: Array
      },
      currentPage: {
        required: true,
        type: Number
      },
      total: {
        required: true,
        type: Number
      },
      pageSize: {
        required: true,
        type: Number
      },
      formItemList: {
        required: true,
        type: Array
      }
    }
  },
  methods: {
    handleSizeChange (val) {
      this.$emit('changePageSize', val)
    },
    handleCurrentChange (val) {
      this.$emit('changeCurrentPage', val)
    }
  }
}
</script>
<style lang="less">
  .my-table {
    padding-top: 15px;
    .mid {
      display: flex;
      line-height: 44px;
      div {
        margin-right: 20px;
        span {
          color: #606266;
        }
      }
    }
    .el-form {
      display: flex;
    }
    .el-form-item {
      display: flex;
      margin-right: 15px;
    }
    .my-input {
      width: 180px;
    }
    .btn {
      margin-left: 20px;
      width: 80px;
    }
    .el-pagination {
      text-align: center;
      padding-top: 15px;
    }
  }
</style>
